import 'dart:collection';

import 'package:flutter/material.dart';

class BaseRefreshController extends ChangeNotifier {
  Map<String, dynamic> _params = new HashMap();

  bool _isSearch = false;

  Map<String, dynamic> get params => _params;

  bool get isSearch => _isSearch;

  BaseRefreshController({Map<String, dynamic> initParams = const {}}) {
    this._params.addAll(initParams);
  }

  resetInitParams(Map<String, dynamic> params) {
    this._params.addAll(params);
  }

  refresh({Map<String, dynamic> params, bool isSearch = false}) {
    this._isSearch = isSearch;
    if (params != null) {
      this._params.addAll(params);
    }
    if (hasListeners) notifyListeners();
  }

  void clearParams() {
    this._params = {};
  }
}
